package com.tourlaid.mamagerment.action.pc

import com.tourlaid.mamagerment.ao.pc.SupplierAo
import com.tourlaid.mamagerment.entity.ResponseData
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController
import javax.annotation.Resource

/**
 * Created by xiaoyongge on 2017/7/23.
 * 供应商
 */
@RestController
@RequestMapping("/tld/admin/supplier")
class SupplierAction {

    @Resource
    var supplierAo: SupplierAo? = null

    @RequestMapping("/list.json")
    fun list(@RequestParam(defaultValue = "1") pageNo: Int,
             @RequestParam(defaultValue = "10") pageSize: Int,
             callback: String): String {
        val ResponseData = supplierAo!!.list(pageNo, pageSize);
        return ResponseData.toJson(callback)
    }


    @RequestMapping("/insert.json")
    fun insert(supplierName: String?, controlNo: String?, callback: String): String {
        supplierAo!!.insert(supplierName, controlNo);
        return ResponseData<String>().toJson(callback)
    }

    @RequestMapping("/detail.json")
    fun detail(supplierId: Long?, callback: String): String {
        var supplierVo = supplierAo!!.detail(supplierId);
        return ResponseData(supplierVo).toJson(callback)
    }

    @RequestMapping("/update.json")
    fun update(supplierId: Long?, supplierName: String?, controlNo: String?, callback: String): String {
        supplierAo!!.update(supplierId, supplierName, controlNo);
        return ResponseData<String>().toJson(callback)
    }

    @RequestMapping("/delete.json")
    fun delete(supplierId: Long?, callback: String): String {
        supplierAo!!.delete(supplierId);
        return ResponseData<String>().toJson(callback)
    }
}